package com.study.lk.exe2.lk;

abstract class Sound {//抽象声音类

    public abstract void phonate();
}

class ConcreteSound extends Sound {//具体声音类

    public void phonate() {
        System.out.println("声音播放:!");
    }
}

abstract class Lamp {//抽象灯光类

    public abstract void twinkle();
}

class ConcreteLamp extends Lamp {//具体灯光类

    public void twinkle() {
        System.out.println("灯光闪烁");
    }
}

abstract class CarController {        //汽车空间类
    public void move() {
        System.out.println("汽车移动！");
    }
    public abstract void sound();
    public abstract void light();
}


class CarAdapter extends CarController { //汽车适配器
    private Sound sound;
    private Lamp lamp;

    public CarAdapter(Sound sound, Lamp lamp) {
        this.sound = sound;
        this.lamp = lamp;
    }

    public void sound() {
        sound.phonate();   //声音播放
    }

    public void light() {
        lamp.twinkle();   //灯光闪烁
    }

}


class Client {

    public static void main(String arg[]) {
        Sound sound;
        Lamp lamp;
        CarController car;
        sound = new ConcreteSound();
        lamp = new ConcreteLamp();
        car = new CarAdapter(sound, lamp);
        car.move();
        car.sound();
        car.light();
    }

}

